package com.yili.oa.dao;

import com.yili.oa.models.User;
import com.yili.oa.models.UserExample.Criteria;
import com.yili.oa.models.UserExample.Criterion;
import com.yili.oa.models.UserExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;

public class UserSqlProvider {

    public String countByExample(UserExample example) {
        SQL sql = new SQL();
        sql.SELECT("count(*)").FROM("t_users");
        applyWhere(sql, example, false);
        return sql.toString();
    }

    public String deleteByExample(UserExample example) {
        SQL sql = new SQL();
        sql.DELETE_FROM("t_users");
        applyWhere(sql, example, false);
        return sql.toString();
    }

    public String insertSelective(User record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("t_users");
        
        if (record.getUserid() != null) {
            sql.VALUES("userid", "#{userid,jdbcType=INTEGER}");
        }
        
        if (record.getWeakMissionData() != null) {
            sql.VALUES("weak_mission_data", "#{weakMissionData,jdbcType=VARCHAR}");
        }
        
        if (record.getAccount() != null) {
            sql.VALUES("account", "#{account,jdbcType=VARCHAR}");
        }
        
        if (record.getName() != null) {
            sql.VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getSex() != null) {
            sql.VALUES("sex", "#{sex,jdbcType=INTEGER}");
        }
        
        if (record.getHeadimg() != null) {
            sql.VALUES("headimg", "#{headimg,jdbcType=VARCHAR}");
        }
        
        if (record.getSignature() != null) {
            sql.VALUES("signature", "#{signature,jdbcType=VARCHAR}");
        }
        
        if (record.getLv() != null) {
            sql.VALUES("lv", "#{lv,jdbcType=SMALLINT}");
        }
        
        if (record.getExp() != null) {
            sql.VALUES("exp", "#{exp,jdbcType=INTEGER}");
        }
        
        if (record.getCoins() != null) {
            sql.VALUES("coins", "#{coins,jdbcType=BIGINT}");
        }
        
        if (record.getGems() != null) {
            sql.VALUES("gems", "#{gems,jdbcType=INTEGER}");
        }
        
        if (record.getStrongbox() != null) {
            sql.VALUES("strongbox", "#{strongbox,jdbcType=BIGINT}");
        }
        
        if (record.getStrongboxPassword() != null) {
            sql.VALUES("strongbox_password", "#{strongboxPassword,jdbcType=VARCHAR}");
        }
        
        if (record.getRoomid() != null) {
            sql.VALUES("roomid", "#{roomid,jdbcType=VARCHAR}");
        }
        
        if (record.getGametype() != null) {
            sql.VALUES("gametype", "#{gametype,jdbcType=VARCHAR}");
        }
        
        if (record.getGamemode() != null) {
            sql.VALUES("gamemode", "#{gamemode,jdbcType=VARCHAR}");
        }
        
        if (record.getServerkey() != null) {
            sql.VALUES("serverkey", "#{serverkey,jdbcType=VARCHAR}");
        }
        
        if (record.getHistory() != null) {
            sql.VALUES("history", "#{history,jdbcType=VARCHAR}");
        }
        
        if (record.getToken() != null) {
            sql.VALUES("token", "#{token,jdbcType=VARCHAR}");
        }
        
        if (record.getInvitorId() != null) {
            sql.VALUES("invitor_id", "#{invitorId,jdbcType=INTEGER}");
        }
        
        if (record.getAgentId() != null) {
            sql.VALUES("agent_id", "#{agentId,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=INTEGER}");
        }
        
        if (record.getLastShareTime() != null) {
            sql.VALUES("last_share_time", "#{lastShareTime,jdbcType=BIGINT}");
        }
        
        if (record.getHighercode() != null) {
            sql.VALUES("highercode", "#{highercode,jdbcType=VARCHAR}");
        }
        
        if (record.getUserWin() != null) {
            sql.VALUES("user_win", "#{userWin,jdbcType=VARCHAR}");
        }
        
        if (record.getUserBout() != null) {
            sql.VALUES("user_bout", "#{userBout,jdbcType=VARCHAR}");
        }
        
        if (record.getEnable() != null) {
            sql.VALUES("enable", "#{enable,jdbcType=TINYINT}");
        }
        
        if (record.getLastLoginTime() != null) {
            sql.VALUES("last_login_time", "#{lastLoginTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getIsRobot() != null) {
            sql.VALUES("is_robot", "#{isRobot,jdbcType=INTEGER}");
        }
        
        if (record.getInvitedCount() != null) {
            sql.VALUES("invited_count", "#{invitedCount,jdbcType=INTEGER}");
        }
        
        if (record.getIsAgent() != null) {
            sql.VALUES("is_agent", "#{isAgent,jdbcType=TINYINT}");
        }
        
        if (record.getDevice() != null) {
            sql.VALUES("device", "#{device,jdbcType=VARCHAR}");
        }
        
        if (record.getDeviceUuid() != null) {
            sql.VALUES("device_uuid", "#{deviceUuid,jdbcType=VARCHAR}");
        }
        
        if (record.getIsGuest() != null) {
            sql.VALUES("is_guest", "#{isGuest,jdbcType=INTEGER}");
        }
        
        if (record.getPromotionAwardClaim() != null) {
            sql.VALUES("promotion_award_claim", "#{promotionAwardClaim,jdbcType=SMALLINT}");
        }
        
        if (record.getWeekAwardClaim() != null) {
            sql.VALUES("week_award_claim", "#{weekAwardClaim,jdbcType=SMALLINT}");
        }
        
        if (record.getMonthAwardClaim() != null) {
            sql.VALUES("month_award_claim", "#{monthAwardClaim,jdbcType=SMALLINT}");
        }
        
        return sql.toString();
    }

    public String selectByExample(UserExample example) {
        SQL sql = new SQL();
        if (example != null && example.isDistinct()) {
            sql.SELECT_DISTINCT("userid");
        } else {
            sql.SELECT("userid");
        }
        sql.SELECT("weak_mission_data");
        sql.SELECT("account");
        sql.SELECT("name");
        sql.SELECT("sex");
        sql.SELECT("headimg");
        sql.SELECT("signature");
        sql.SELECT("lv");
        sql.SELECT("exp");
        sql.SELECT("coins");
        sql.SELECT("gems");
        sql.SELECT("strongbox");
        sql.SELECT("strongbox_password");
        sql.SELECT("roomid");
        sql.SELECT("gametype");
        sql.SELECT("gamemode");
        sql.SELECT("serverkey");
        sql.SELECT("history");
        sql.SELECT("token");
        sql.SELECT("invitor_id");
        sql.SELECT("agent_id");
        sql.SELECT("create_time");
        sql.SELECT("last_share_time");
        sql.SELECT("highercode");
        sql.SELECT("user_win");
        sql.SELECT("user_bout");
        sql.SELECT("enable");
        sql.SELECT("last_login_time");
        sql.SELECT("is_robot");
        sql.SELECT("invited_count");
        sql.SELECT("is_agent");
        sql.SELECT("device");
        sql.SELECT("device_uuid");
        sql.SELECT("is_guest");
        sql.SELECT("promotion_award_claim");
        sql.SELECT("week_award_claim");
        sql.SELECT("month_award_claim");
        sql.FROM("t_users");
        applyWhere(sql, example, false);
        
        if (example != null && example.getOrderByClause() != null) {
            sql.ORDER_BY(example.getOrderByClause());
        }
        
        return sql.toString();
    }

    public String updateByExampleSelective(Map<String, Object> parameter) {
        User record = (User) parameter.get("record");
        UserExample example = (UserExample) parameter.get("example");
        
        SQL sql = new SQL();
        sql.UPDATE("t_users");
        
        if (record.getUserid() != null) {
            sql.SET("userid = #{record.userid,jdbcType=INTEGER}");
        }
        
        if (record.getWeakMissionData() != null) {
            sql.SET("weak_mission_data = #{record.weakMissionData,jdbcType=VARCHAR}");
        }
        
        if (record.getAccount() != null) {
            sql.SET("account = #{record.account,jdbcType=VARCHAR}");
        }
        
        if (record.getName() != null) {
            sql.SET("name = #{record.name,jdbcType=VARCHAR}");
        }
        
        if (record.getSex() != null) {
            sql.SET("sex = #{record.sex,jdbcType=INTEGER}");
        }
        
        if (record.getHeadimg() != null) {
            sql.SET("headimg = #{record.headimg,jdbcType=VARCHAR}");
        }
        
        if (record.getSignature() != null) {
            sql.SET("signature = #{record.signature,jdbcType=VARCHAR}");
        }
        
        if (record.getLv() != null) {
            sql.SET("lv = #{record.lv,jdbcType=SMALLINT}");
        }
        
        if (record.getExp() != null) {
            sql.SET("exp = #{record.exp,jdbcType=INTEGER}");
        }
        
        if (record.getCoins() != null) {
            sql.SET("coins = #{record.coins,jdbcType=BIGINT}");
        }
        
        if (record.getGems() != null) {
            sql.SET("gems = #{record.gems,jdbcType=INTEGER}");
        }
        
        if (record.getStrongbox() != null) {
            sql.SET("strongbox = #{record.strongbox,jdbcType=BIGINT}");
        }
        
        if (record.getStrongboxPassword() != null) {
            sql.SET("strongbox_password = #{record.strongboxPassword,jdbcType=VARCHAR}");
        }
        
        if (record.getRoomid() != null) {
            sql.SET("roomid = #{record.roomid,jdbcType=VARCHAR}");
        }
        
        if (record.getGametype() != null) {
            sql.SET("gametype = #{record.gametype,jdbcType=VARCHAR}");
        }
        
        if (record.getGamemode() != null) {
            sql.SET("gamemode = #{record.gamemode,jdbcType=VARCHAR}");
        }
        
        if (record.getServerkey() != null) {
            sql.SET("serverkey = #{record.serverkey,jdbcType=VARCHAR}");
        }
        
        if (record.getHistory() != null) {
            sql.SET("history = #{record.history,jdbcType=VARCHAR}");
        }
        
        if (record.getToken() != null) {
            sql.SET("token = #{record.token,jdbcType=VARCHAR}");
        }
        
        if (record.getInvitorId() != null) {
            sql.SET("invitor_id = #{record.invitorId,jdbcType=INTEGER}");
        }
        
        if (record.getAgentId() != null) {
            sql.SET("agent_id = #{record.agentId,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{record.createTime,jdbcType=INTEGER}");
        }
        
        if (record.getLastShareTime() != null) {
            sql.SET("last_share_time = #{record.lastShareTime,jdbcType=BIGINT}");
        }
        
        if (record.getHighercode() != null) {
            sql.SET("highercode = #{record.highercode,jdbcType=VARCHAR}");
        }
        
        if (record.getUserWin() != null) {
            sql.SET("user_win = #{record.userWin,jdbcType=VARCHAR}");
        }
        
        if (record.getUserBout() != null) {
            sql.SET("user_bout = #{record.userBout,jdbcType=VARCHAR}");
        }
        
        if (record.getEnable() != null) {
            sql.SET("enable = #{record.enable,jdbcType=TINYINT}");
        }
        
        if (record.getLastLoginTime() != null) {
            sql.SET("last_login_time = #{record.lastLoginTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getIsRobot() != null) {
            sql.SET("is_robot = #{record.isRobot,jdbcType=INTEGER}");
        }
        
        if (record.getInvitedCount() != null) {
            sql.SET("invited_count = #{record.invitedCount,jdbcType=INTEGER}");
        }
        
        if (record.getIsAgent() != null) {
            sql.SET("is_agent = #{record.isAgent,jdbcType=TINYINT}");
        }
        
        if (record.getDevice() != null) {
            sql.SET("device = #{record.device,jdbcType=VARCHAR}");
        }
        
        if (record.getDeviceUuid() != null) {
            sql.SET("device_uuid = #{record.deviceUuid,jdbcType=VARCHAR}");
        }
        
        if (record.getIsGuest() != null) {
            sql.SET("is_guest = #{record.isGuest,jdbcType=INTEGER}");
        }
        
        if (record.getPromotionAwardClaim() != null) {
            sql.SET("promotion_award_claim = #{record.promotionAwardClaim,jdbcType=SMALLINT}");
        }
        
        if (record.getWeekAwardClaim() != null) {
            sql.SET("week_award_claim = #{record.weekAwardClaim,jdbcType=SMALLINT}");
        }
        
        if (record.getMonthAwardClaim() != null) {
            sql.SET("month_award_claim = #{record.monthAwardClaim,jdbcType=SMALLINT}");
        }
        
        applyWhere(sql, example, true);
        return sql.toString();
    }

    public String updateByExample(Map<String, Object> parameter) {
        SQL sql = new SQL();
        sql.UPDATE("t_users");
        
        sql.SET("userid = #{record.userid,jdbcType=INTEGER}");
        sql.SET("weak_mission_data = #{record.weakMissionData,jdbcType=VARCHAR}");
        sql.SET("account = #{record.account,jdbcType=VARCHAR}");
        sql.SET("name = #{record.name,jdbcType=VARCHAR}");
        sql.SET("sex = #{record.sex,jdbcType=INTEGER}");
        sql.SET("headimg = #{record.headimg,jdbcType=VARCHAR}");
        sql.SET("signature = #{record.signature,jdbcType=VARCHAR}");
        sql.SET("lv = #{record.lv,jdbcType=SMALLINT}");
        sql.SET("exp = #{record.exp,jdbcType=INTEGER}");
        sql.SET("coins = #{record.coins,jdbcType=BIGINT}");
        sql.SET("gems = #{record.gems,jdbcType=INTEGER}");
        sql.SET("strongbox = #{record.strongbox,jdbcType=BIGINT}");
        sql.SET("strongbox_password = #{record.strongboxPassword,jdbcType=VARCHAR}");
        sql.SET("roomid = #{record.roomid,jdbcType=VARCHAR}");
        sql.SET("gametype = #{record.gametype,jdbcType=VARCHAR}");
        sql.SET("gamemode = #{record.gamemode,jdbcType=VARCHAR}");
        sql.SET("serverkey = #{record.serverkey,jdbcType=VARCHAR}");
        sql.SET("history = #{record.history,jdbcType=VARCHAR}");
        sql.SET("token = #{record.token,jdbcType=VARCHAR}");
        sql.SET("invitor_id = #{record.invitorId,jdbcType=INTEGER}");
        sql.SET("agent_id = #{record.agentId,jdbcType=VARCHAR}");
        sql.SET("create_time = #{record.createTime,jdbcType=INTEGER}");
        sql.SET("last_share_time = #{record.lastShareTime,jdbcType=BIGINT}");
        sql.SET("highercode = #{record.highercode,jdbcType=VARCHAR}");
        sql.SET("user_win = #{record.userWin,jdbcType=VARCHAR}");
        sql.SET("user_bout = #{record.userBout,jdbcType=VARCHAR}");
        sql.SET("enable = #{record.enable,jdbcType=TINYINT}");
        sql.SET("last_login_time = #{record.lastLoginTime,jdbcType=TIMESTAMP}");
        sql.SET("is_robot = #{record.isRobot,jdbcType=INTEGER}");
        sql.SET("invited_count = #{record.invitedCount,jdbcType=INTEGER}");
        sql.SET("is_agent = #{record.isAgent,jdbcType=TINYINT}");
        sql.SET("device = #{record.device,jdbcType=VARCHAR}");
        sql.SET("device_uuid = #{record.deviceUuid,jdbcType=VARCHAR}");
        sql.SET("is_guest = #{record.isGuest,jdbcType=INTEGER}");
        sql.SET("promotion_award_claim = #{record.promotionAwardClaim,jdbcType=SMALLINT}");
        sql.SET("week_award_claim = #{record.weekAwardClaim,jdbcType=SMALLINT}");
        sql.SET("month_award_claim = #{record.monthAwardClaim,jdbcType=SMALLINT}");
        
        UserExample example = (UserExample) parameter.get("example");
        applyWhere(sql, example, true);
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(User record) {
        SQL sql = new SQL();
        sql.UPDATE("t_users");
        
        if (record.getWeakMissionData() != null) {
            sql.SET("weak_mission_data = #{weakMissionData,jdbcType=VARCHAR}");
        }
        
        if (record.getAccount() != null) {
            sql.SET("account = #{account,jdbcType=VARCHAR}");
        }
        
        if (record.getName() != null) {
            sql.SET("name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getSex() != null) {
            sql.SET("sex = #{sex,jdbcType=INTEGER}");
        }
        
        if (record.getHeadimg() != null) {
            sql.SET("headimg = #{headimg,jdbcType=VARCHAR}");
        }
        
        if (record.getSignature() != null) {
            sql.SET("signature = #{signature,jdbcType=VARCHAR}");
        }
        
        if (record.getLv() != null) {
            sql.SET("lv = #{lv,jdbcType=SMALLINT}");
        }
        
        if (record.getExp() != null) {
            sql.SET("exp = #{exp,jdbcType=INTEGER}");
        }
        
        if (record.getCoins() != null) {
            sql.SET("coins = #{coins,jdbcType=BIGINT}");
        }
        
        if (record.getGems() != null) {
            sql.SET("gems = #{gems,jdbcType=INTEGER}");
        }
        
        if (record.getStrongbox() != null) {
            sql.SET("strongbox = #{strongbox,jdbcType=BIGINT}");
        }
        
        if (record.getStrongboxPassword() != null) {
            sql.SET("strongbox_password = #{strongboxPassword,jdbcType=VARCHAR}");
        }
        
        if (record.getRoomid() != null) {
            sql.SET("roomid = #{roomid,jdbcType=VARCHAR}");
        }
        
        if (record.getGametype() != null) {
            sql.SET("gametype = #{gametype,jdbcType=VARCHAR}");
        }
        
        if (record.getGamemode() != null) {
            sql.SET("gamemode = #{gamemode,jdbcType=VARCHAR}");
        }
        
        if (record.getServerkey() != null) {
            sql.SET("serverkey = #{serverkey,jdbcType=VARCHAR}");
        }
        
        if (record.getHistory() != null) {
            sql.SET("history = #{history,jdbcType=VARCHAR}");
        }
        
        if (record.getToken() != null) {
            sql.SET("token = #{token,jdbcType=VARCHAR}");
        }
        
        if (record.getInvitorId() != null) {
            sql.SET("invitor_id = #{invitorId,jdbcType=INTEGER}");
        }
        
        if (record.getAgentId() != null) {
            sql.SET("agent_id = #{agentId,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=INTEGER}");
        }
        
        if (record.getLastShareTime() != null) {
            sql.SET("last_share_time = #{lastShareTime,jdbcType=BIGINT}");
        }
        
        if (record.getHighercode() != null) {
            sql.SET("highercode = #{highercode,jdbcType=VARCHAR}");
        }
        
        if (record.getUserWin() != null) {
            sql.SET("user_win = #{userWin,jdbcType=VARCHAR}");
        }
        
        if (record.getUserBout() != null) {
            sql.SET("user_bout = #{userBout,jdbcType=VARCHAR}");
        }
        
        if (record.getEnable() != null) {
            sql.SET("enable = #{enable,jdbcType=TINYINT}");
        }
        
        if (record.getLastLoginTime() != null) {
            sql.SET("last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getIsRobot() != null) {
            sql.SET("is_robot = #{isRobot,jdbcType=INTEGER}");
        }
        
        if (record.getInvitedCount() != null) {
            sql.SET("invited_count = #{invitedCount,jdbcType=INTEGER}");
        }
        
        if (record.getIsAgent() != null) {
            sql.SET("is_agent = #{isAgent,jdbcType=TINYINT}");
        }
        
        if (record.getDevice() != null) {
            sql.SET("device = #{device,jdbcType=VARCHAR}");
        }
        
        if (record.getDeviceUuid() != null) {
            sql.SET("device_uuid = #{deviceUuid,jdbcType=VARCHAR}");
        }
        
        if (record.getIsGuest() != null) {
            sql.SET("is_guest = #{isGuest,jdbcType=INTEGER}");
        }
        
        if (record.getPromotionAwardClaim() != null) {
            sql.SET("promotion_award_claim = #{promotionAwardClaim,jdbcType=SMALLINT}");
        }
        
        if (record.getWeekAwardClaim() != null) {
            sql.SET("week_award_claim = #{weekAwardClaim,jdbcType=SMALLINT}");
        }
        
        if (record.getMonthAwardClaim() != null) {
            sql.SET("month_award_claim = #{monthAwardClaim,jdbcType=SMALLINT}");
        }
        
        sql.WHERE("userid = #{userid,jdbcType=INTEGER}");
        
        return sql.toString();
    }

    protected void applyWhere(SQL sql, UserExample example, boolean includeExamplePhrase) {
        if (example == null) {
            return;
        }
        
        String parmPhrase1;
        String parmPhrase1_th;
        String parmPhrase2;
        String parmPhrase2_th;
        String parmPhrase3;
        String parmPhrase3_th;
        if (includeExamplePhrase) {
            parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
            parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
            parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
            parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
            parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
            parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
        } else {
            parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
            parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
            parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
            parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
            parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
            parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
        }
        
        StringBuilder sb = new StringBuilder();
        List<Criteria> oredCriteria = example.getOredCriteria();
        boolean firstCriteria = true;
        for (int i = 0; i < oredCriteria.size(); i++) {
            Criteria criteria = oredCriteria.get(i);
            if (criteria.isValid()) {
                if (firstCriteria) {
                    firstCriteria = false;
                } else {
                    sb.append(" or ");
                }
                
                sb.append('(');
                List<Criterion> criterions = criteria.getAllCriteria();
                boolean firstCriterion = true;
                for (int j = 0; j < criterions.size(); j++) {
                    Criterion criterion = criterions.get(j);
                    if (firstCriterion) {
                        firstCriterion = false;
                    } else {
                        sb.append(" and ");
                    }
                    
                    if (criterion.isNoValue()) {
                        sb.append(criterion.getCondition());
                    } else if (criterion.isSingleValue()) {
                        if (criterion.getTypeHandler() == null) {
                            sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
                        } else {
                            sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
                        }
                    } else if (criterion.isBetweenValue()) {
                        if (criterion.getTypeHandler() == null) {
                            sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
                        } else {
                            sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
                        }
                    } else if (criterion.isListValue()) {
                        sb.append(criterion.getCondition());
                        sb.append(" (");
                        List<?> listItems = (List<?>) criterion.getValue();
                        boolean comma = false;
                        for (int k = 0; k < listItems.size(); k++) {
                            if (comma) {
                                sb.append(", ");
                            } else {
                                comma = true;
                            }
                            if (criterion.getTypeHandler() == null) {
                                sb.append(String.format(parmPhrase3, i, j, k));
                            } else {
                                sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
                            }
                        }
                        sb.append(')');
                    }
                }
                sb.append(')');
            }
        }
        
        if (sb.length() > 0) {
            sql.WHERE(sb.toString());
        }
    }
}